accountingIntegrationDashboardApp.controller('maintenanceCompanyCtrl', ['$scope', '$http', '$log', 'serverDataService', 'commonValidationService', function ($scope, $http, $log, serverDataService, commonValidationService){ 

    $scope.countries = [];
    $scope.entityName = 'company';
    
    $scope.setChildScope($scope);

    $scope.renderRecordsFromServer();

    $scope.loadCountries = function(){
        return $scope.countries.length ? null : serverDataService.getEntityList('country', false)
                .then(function (data){
                    $scope.countries = data.gridRecords;
                });
    };
    
    //Specific entity columns
    $scope.addCompany = function() {
        $scope.inserted = {
          id: null,
          code: null,
          description: null,
          country: null
        };
        $scope.gridRecords.push($scope.inserted);
    };
    
    //customized validations for columns
    $scope.validateCode = function (columnName, data){
    	$scope.validateCodeMsg = null;
    	msg = commonValidationService.checkNotEmpty(columnName, data);
    	if (msg) {return msg;}
    	msg = commonValidationService.checkNumbersOnly(columnName, data);
    	if (msg) {return msg;}
    };
    
}]);